package com.itxiao.controller;

import com.itxiao.annotation.Token;
import com.itxiao.entity.Category;
import com.itxiao.entity.SysUser;
import com.itxiao.pojo.bo.Page;
import com.itxiao.pojo.vo.R;
import com.itxiao.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;

/**
 * (Category)表控制层
 *
 * @author makejava
 * @since 2025-10-12 17:07:25
 */
@RestController
@RequestMapping("admin/api/v1/category")
@Api(tags = "分类模块")
@CrossOrigin
public class CategoryController {
    /**
     * 服务对象
     */
    @Resource
    private CategoryService categoryService;

    @ApiOperation("分页查询")
    @PostMapping("/query")
    public R queryList(@RequestBody Page page) {
        return categoryService.queryList(page);
    }

    @ApiOperation("添")
    @PostMapping("/add")
    public R add(@RequestBody Category category) {
        return categoryService.add(category);
    }

    @ApiOperation("修改")
    @PutMapping("/update")
    public R update(@RequestBody Category category) {
        return categoryService.updateInfo(category);
    }

    @ApiOperation("单个删除")
    @DeleteMapping("/delete/{id}")
    public R deleteById(@PathVariable Integer id) {
        return categoryService.del(Collections.singletonList(id));
    }

}

